﻿using PSE.Deployment.SetupBase.Configuration;

namespace PSE.Deployment.ConfigurationManager.Controls
{
	/// <summary>
	/// UserControl que instancia uma classe para ser vinculada a Grupos
	/// </summary>
	public class GroupTreeViewItem : TreeViewItemBase
	{
		bool _isOnUpdateGroup = false;
		Group _group = null;

		public bool IsOnUpdateGroup
		{
			get { return _isOnUpdateGroup; }
			set
			{
				_isOnUpdateGroup = value;
				if (base.ParentItem != null && !base.ParentItem.HasUpdateConfigInsideSubGroup && _group != null && _group.Installed)
					base.ParentItem.HasUpdateConfigInsideSubGroup = value;
			}
		}
		public Group Group
		{
			get { return _group; }
			set { _group = value; }
		}

		public GroupTreeViewItem(string header)
		{
			this.Header = header;
		}

		public GroupTreeViewItem(string header, bool isUpdateConfig) : this(header)
		{
			this.IsOnUpdateGroup = isUpdateConfig;
		}

		public GroupTreeViewItem(string header, bool isUpdateConfig, GroupTreeViewItem parentItem) : this(header)
		{
			this.ParentItem = parentItem;
			this.IsOnUpdateGroup = isUpdateConfig;
		}

		public GroupTreeViewItem(string header, bool isUpdateConfig, GroupTreeViewItem parentItem, Group group) : this(header)
		{
			this.ParentItem = parentItem;
			this.IsOnUpdateGroup = isUpdateConfig;
			this.Group = group;
		}
	}
}